<template>
  
  <div class="background">
    
    <div class="form-container">
      <Login v-if="!flag" @toggle="changeFlag" />
      <Register v-else @toggle="changeFlag" />
      <button @click="changeFlag">{{ flag ? '已有账号，立即登录' : '没有账号，在线注册' }}</button>
    </div>
  </div>
</template>

<script setup>
import { ref } from 'vue';
import Login from '@/views/Login.vue';
import Register from '@/views/Register.vue';

const flag = ref(true);

function changeFlag () {
  flag.value = !flag.value;
}
</script>

<style scoped>
.background {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100vw;
  height: 90vh;
  background-image: url('./img/image.png');
  background-size: cover;
  background-repeat: no-repeat;
  background-position: center;
}

.form-container {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 50%;
  height: 50%;
  padding: 2rem; 
  border-radius: 8px; 
}

button {
  padding: 0.5rem 1rem;
  border: none;
  background-color: #007BFF;
  color: white;
  border-radius: 4px;
  cursor: pointer;
}

button:hover {
  background-color: #0056b3;
}
</style>